import 'package:flutter/material.dart';

class SearchPage extends StatefulWidget{
  SearchPage({Key key}) :super(key:key);
  _SearchPageState createState()=> _SearchPageState();
}
class _SearchPageState extends State<SearchPage>{
  
  TextEditingController _controller;

  @override
  void initState() {
    super.initState();
    _controller = TextEditingController();
  }
  @override
  Widget build(BuildContext context){
    return Scaffold(
      appBar: AppBar(
        actions: <Widget>[
          Container(
            width: 300.0,
          margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
          child: TextFileWidget(),
          )
          
        ],
          
        
        
      )
    );
  }
}
class TextFileWidget extends StatelessWidget {
  
  Widget buildTextField() {
    return Container(
      // width: 200.0,
      margin: EdgeInsets.fromLTRB(0, 0, 20, 0),
      child:TextField(
      autofocus: true,
      controller: TextEditingController(),
      cursorColor: Colors.white, 
      decoration: InputDecoration(
          contentPadding: new EdgeInsets.only(left: 0.0,top: 8),
          border: InputBorder.none,
          icon: Icon(Icons.search,color: Colors.white,),
          hintText: "请输入关键词",
          suffixIcon: IconButton(icon: Icon(Icons.clear,color: Colors.white,),
          padding: EdgeInsets.only(left: 30.0),
          onPressed: (){
            TextEditingController(text: '');
          },),
          hintStyle: new TextStyle(fontSize: 14, color: Colors.white)),
      style: new TextStyle(fontSize: 16, color: Colors.white,),
    )
    );
    
  }

  @override
  Widget build(BuildContext context) {
    Widget editView() {
      return Container(
        width: 300.0,
        decoration: new BoxDecoration(
          color: Color.fromRGBO(255, 255, 255, 0.3),
          borderRadius: new BorderRadius.all(new Radius.circular(15.0)),
        ),
        alignment: Alignment.center,
        height: 36,
        padding: EdgeInsets.fromLTRB(10.0, 0.0, 0.0, 0.0),
        child: buildTextField(),
      );
    }

    return

      Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Expanded(
          child: editView(),
          flex: 1,
        ),
      ],
    );
  }
}